﻿namespace DataIntegration.Messaging.Publisher.ActiveMQ
{
    using Apache.NMS;
    using Apache.NMS.ActiveMQ;
    using Entities;

    public class ActiveMQPublisherFactory : IPublisherFactory
    {
        private string url;

        public ActiveMQPublisherFactory(string url)
        {
            this.url = url;
        }

        public IPublisher GetPublisher(string daemon, MessageType messageType, string component)
        {
            string clientId = string.Format("Publisher.{0}.{1}.{2}", daemon, messageType, component);
            IConnectionFactory connectionFactory = new ConnectionFactory(this.url, clientId);
            return new ActiveMQPublisher(connectionFactory);
        }
    }
}